package oop5;

/**
 * @author oldliu
 * @since 1.0
 */
public class Student {
    private String name;
    private int  age;
    private String phone;
    public Student(){
    }

    public Student(String name, int age, String phone) {
        this.name = name;
        //this.age = age;
        setAge(age);//调用一下
        this.phone = phone;
    }

    public String getName(){
        return  name;
    }
    public void setName(String n){
        this.name=n;
    }
    public String getPhone(){
        return phone;
    }
    public void setPhone(String phone){
        this.phone=phone;
    }
    public int getAge(){
        return this.age;
    }
    //所有对年龄的修改，经过了setAge方法
    public void setAge(int a){
        if(a>=14 &&a<=100){
            age=a;
            return;
        }
        System.out.println("年龄"+a+"不合法！");
    }

    public void show(){
        System.out.println("这个学生叫"+name+",年龄是"+age+"岁,手机号是"+phone);
    }
}
